<?php
/**
 * Created by PhpStorm.
 * User: lz
 * Date: 2017/8/15
 * Time: 17:06
 */

namespace app\assets;

use yii\web\AssetBundle;
use app\common\service\UrlService;
use app\common\service\UtilService;

class CustomerAsset extends AssetBundle
{
    public $basePath = '@webroot';
    public $baseUrl = '@web';
    public $css = [
    ];
    public $js = [
    ];

    public function registerAssetFiles($view)
    {
        //加一个版本号,目的 ： 是浏览器获取最新的css 和 js 文件
        $release_version = defined("RELEASE_VERSION") ? RELEASE_VERSION : time();
        $this->css = [
            UrlService::buildIndexUrl("/font-awesome/css/font-awesome.css"),
            UrlService::buildIndexUrl("/css/m/css_style.css"),
            UrlService::buildIndexUrl("/css/m/home_page.css"),
            UrlService::buildIndexUrl("/css/m/app.css", ['ver' => $release_version]),
        ];

        if (UtilService::isWechat()) {
            $this->js = [
                'https://res.wx.qq.com/open/js/jweixin-1.0.0.js',
                UrlService::buildIndexUrl("/plugins/jquery-2.1.1.js"),
                UrlService::buildIndexUrl("/js/m/TouchSlide.1.1.js"),
                UrlService::buildIndexUrl("/js/m/common.js", ['ver' => $release_version]),
                UrlService::buildIndexUrl("/js/m/weixin.js"),
            ];
        } else {
            $this->js = [
                'https://res.wx.qq.com/open/js/jweixin-1.0.0.js',
                UrlService::buildIndexUrl("/plugins/jquery-2.1.1.js"),
                UrlService::buildIndexUrl("/js/m/TouchSlide.1.1.js"),
                UrlService::buildIndexUrl("/js/m/common.js", ['ver' => $release_version])
            ];
        }

        parent::registerAssetFiles($view);
    }
}

